<?php
/*
 * Author: Omar
 */
class Application_Form_SearchForm extends Zend_Dojo_Form
{

    public function init()
    {

       $productTable = RepProductTable::getInstance();
       $accountTable = AccountTable::getInstance();
       $publisherTable = PublisherTable::getInstance();
        /* Form Elements & Other Definitions Here ... */
        $this->setAction('/');
        $this->setMethod('GET');
        $this->setAttrib('id','form');
        
        $status = new Zend_Dojo_Form_Element_FilteringSelect('status');
        $status->setLabel('Status');
        $status->addMultiOptions(array('0' => 'Any'));
        $status->addMultiOptions(array_combine($productTable->getEnumValues('completedStatus'),$productTable->getEnumValues('completedStatus')) );
//------------------------------------------------------------------------------
        $createdBy = new Zend_Dojo_Form_Element_FilteringSelect('createdBy');
        $createdBy->setLabel('Created By');
        $createdBy->addMultiOptions(array('0' => 'Any'));
        $createdBy->addMultiOptions($accountTable->getNames() );
//------------------------------------------------------------------------------
        $publisher = new Zend_Dojo_Form_Element_FilteringSelect('publisher');
        $publisher->setLabel('Publisher');
        $publisher->addMultiOptions(array('0' => 'Any'));
        $publisher->addMultiOptions($publisherTable->getNames());
//------------------------------------------------------------------------------
        $supervisor = new Zend_Dojo_Form_Element_FilteringSelect('supervisor');
        $supervisor->setLabel('Supervisor');
        $supervisor->addMultiOptions(array('0' => 'Any'));
        $supervisor->addMultiOptions($accountTable->getNames('supervisor'));
//------------------------------------------------------------------------------
        $authorization = new Zend_Dojo_Form_Element_FilteringSelect('authorization');
        $authorization->setLabel('Authorization state');
        $authorization->addMultiOptions(array('0' => 'Any'));
        $authorization->addMultiOptions( array_combine($productTable->getEnumValues('revision') ,$productTable->getEnumValues('revision') ));
        $authorization->addMultiOptions(array('Unauthorized' => 'Unauthorized'));
//------------------------------------------------------------------------------
        
        $from=new Zend_Dojo_Form_Element_DateTextBox('from',array('label' => 'From'));
        $from->addValidator(new Lib_DateValidator());
                
        $to=new Zend_Dojo_Form_Element_DateTextBox('to',array('label' => 'To'));
        $to->addValidator(new Lib_DateValidator());
//------------------------------------------------------------------------------
        $submit = new Zend_Form_Element_Submit('submit');
        
        $this->addElements(array(
            $status,
            $createdBy,
            $authorization,
            $supervisor,
            $publisher,$from,$to,
            $submit
        ));
    }

}

